package com.cgd.appointment.controller;

import com.cgd.appointment.entity.Users;
import com.cgd.appointment.service.IUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/users")
public class UsersController {
    @Autowired
    private IUsersService iUsersService;
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public Users login(@RequestParam String username){
        return iUsersService.findlogin(username);
    }
    @RequestMapping(value = "/addusers",method = RequestMethod.POST)
    public void addusers(@RequestParam String username,@RequestParam String password){
        iUsersService.addusers(username,password);
    }
    @RequestMapping(value = "/addadmins",method = RequestMethod.POST)
    public void addadmins(@RequestBody Users users) { iUsersService.addadmins(users); }//新增管理员
    //@RequestMapping(value = "/listusers",method = RequestMethod.POST)
    @GetMapping("/listusers")
    public List<Users> listusers() { return iUsersService.listusers(); }//列出用户
    @RequestMapping(value = "/addmess",method = RequestMethod.POST)
    public void addmess(@RequestParam String mobile,@RequestParam String username,@RequestParam String wechat,@RequestParam int loginid){
        iUsersService.addmess(mobile,username,wechat,loginid);
    }
    @RequestMapping(value = "/findbyloginid",method = RequestMethod.POST)
    public Users findbyloginid(@RequestParam int loginid){
        return iUsersService.findbyloginid(loginid);
    }
    @RequestMapping(value = "/deleteuser",method = RequestMethod.POST)
    public void deleteuser(@RequestParam String username) { iUsersService.deleteuser(username); }
    //修改密码
    @RequestMapping(value = "/updatepassword",method = RequestMethod.POST)
    public void updatepassword(@RequestParam String username,@RequestParam String password) { iUsersService.updatepassword(username,password); }
}
